package proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author shenhan
 * @create 2020/1/17 9:46
 * @description
 */
public class MyMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        doBefore();
        final Object invokeSuper = proxy.invokeSuper(obj, args);
        doAfter();
        return invokeSuper;
    }

    private void doAfter() {
        System.out.println("后置业务逻辑");
    }

    private void doBefore() {
        System.out.println("前置业务逻辑");
    }
}
